package com.example.demo_1106.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.demo_1106.entity.ShoppingCart;
import com.example.demo_1106.service.ShoppingCartService;
import com.example.demo_1106.mapper.ShoppingCartMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author kongke
 * @description 针对表【shopping_cart】的数据库操作Service实现
 * @createDate 2023-07-23 10:09:06
 */
@Service
public class ShoppingCartServiceImpl extends ServiceImpl<ShoppingCartMapper, ShoppingCart>
        implements ShoppingCartService {

    @Autowired
    ShoppingCartMapper shoppingCartMapper;

    /**
     * 删除搬运信息
     *
     * @param shopcode 货物编号
     * @return boolean
     */
    @Override
    public boolean delShoppingCart(String shopcode) {
        int del = shoppingCartMapper.delete(new QueryWrapper<ShoppingCart>().eq("shopping_cart_code", shopcode));
        return del != 0;
    }

    @Override
    public List<ShoppingCart> getShop(String shopcode) {
        List<ShoppingCart> shoppingCartList;
        if("".equals(shopcode)||shopcode==null){
            shoppingCartList=shoppingCartMapper.selectList(null);
        }else {
            shoppingCartList=shoppingCartMapper.selectList(new QueryWrapper<ShoppingCart>().eq("shopping_cart_code",shopcode));
        }
        return shoppingCartList;
    }
}




